package com.example.sneakerappforme1105.bean;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.PrimaryKey;

@Entity(tableName = "tb_orderItem",
    foreignKeys = {
        @ForeignKey(
                entity = Order.class,
                parentColumns = "orderId",
                childColumns = "orderId",
                onDelete = ForeignKey.CASCADE
        ),
            @ForeignKey(
                    entity = Goods.class,
                    parentColumns = "goodsId",
                    childColumns = "goodsId",
                    onDelete = ForeignKey.CASCADE
            )
    }
)

public class OrderItem {    // 其实就是多对多的关系表, 商品和订单
    @PrimaryKey(autoGenerate = true) // 该字段是自增主键
    @NonNull
    private long orderItemId;
    private long orderId; // 外键 订单
    private long goodsId;  // 外键 商品
    private int num; // 商品数量
    private double price; // 单项商品价格
    private String size; // 鞋码数，衣服尺码
    // 价格可以用映射表  Map<goods_id, Goods>


    public OrderItem(long orderId, long goodsId, int num, double price, String size) {
        this.orderId = orderId;
        this.goodsId = goodsId;
        this.num = num;
        this.price = price;
        this.size = size;
    }

    public long getOrderItemId() {
        return orderItemId;
    }

    public void setOrderItemId(long orderItemId) {
        this.orderItemId = orderItemId;
    }

    public long getOrderId() {
        return orderId;
    }

    public void setOrderId(long orderId) {
        this.orderId = orderId;
    }

    public long getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(long goodsId) {
        this.goodsId = goodsId;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }
}
